package main


type TreeNode struct {
	Val int
	Left *TreeNode
	Right *TreeNode
}

func abs(x int)int {
	if x>=0{
		return x
	}
	return -x
}
func max(a,b int)int{
	if a>=b{
		return a
	}
	return b
}


func helper(root *TreeNode)int{
	if root==nil{
		return 0
	}
	return max(helper(root.Left),helper(root.Right))+1
}

func isBalanced(root *TreeNode) bool {
	if root==nil{
		return true
	}
	return abs(helper(root.Left)-helper(root.Right))<=1 && isBalanced(root.Left) && isBalanced(root.Right)
}

func main(){
	
}
